import Vue from 'vue'
import Router from 'vue-router'
import AppIndex from '@/components/home/AppIndex'
import Login from '@/components/Login'
import Home from '../components/Home'
import Charts from '../components/views/charts/Charts'
import SetupPassword from '../components/views/setup/SetupPassword'
import center from '../components/views/user/center'
import userIndex from '../components/views/system/users/index'
import rolesIndex from '../components/views/system/roles/index'
import menusIndex from '../components/views/system/menus/index'
import dictIndex from '../components/views/system/dict/index'

Vue.use(Router)
const VueRouterPush = Router.prototype.push

Router.prototype.push = function push (to) {

  return VueRouterPush.call(this, to).catch(err => err)

}

export default new Router({
  mode: 'history',
  routes: [
    {
      path: '/home',
      name: 'Home',
      component: Home,
      // home页面不需要被访问
      redirect: '/index',
      children: [
        {
          path: '/index',
          name: 'AppIndex',
          component: AppIndex,
          meta: {
            requireAuth: true
          }
        }, {
          path: '/charts/Charts',
          name: '数据可视化',
          component: Charts,
          meta: {
            requireAuth: true
          }
        }, {
          path: '/user/center',
          name: '个人中心',
          component: center,
          meta: {
            requireAuth: true
          }
        }, {
          path: '/setup/SetupPassword',
          name: '设置',
          component: SetupPassword,
          meta: {
            requireAuth: true
          }
        }, {
          path: '/system/users/index',
          name: '用户管理',
          component: userIndex,
          meta: {
            requireAuth: true
          }
        }, {
          path: '/system/roles/index',
          name: '角色管理',
          component: rolesIndex,
          meta: {
            requireAuth: true
          }
        }, {
          path: '/system/menus/index',
          name: '菜单管理',
          component: menusIndex,
          meta: {
            requireAuth: true
          }
        }, {
          path: '/system/dict/index',
          name: '字典管理',
          component: dictIndex,
          meta: {
            requireAuth: true
          }
        }
      ]
    },
    {
      path: '/login',
      name: 'Login',
      component: Login
    }
  ]
})
